{include app:admin.inc.header}
<!--tmpl-resource-->
{include app:admin.inc.top}

<div class="container-fluid content-body">
	<div class="main">
		<!-- left side start-->

		<section class="left-section">
			<dl id="leftNav" data-type="message">
				<dt><i class="glyphicon glyphicon-plus"></i> 信息管理</dt>
				{if in_case_array('admin/notice',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/notice/index}">公告管理</a></dd>
				{/if}
				{if in_case_array('admin/information',$priv) || empty($priv)}
				<dd><a class="mb active" href="{url /admin/information/index}">资讯管理</a></dd>
				{/if}
				{if in_case_array('admin/singlepage',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/singlepage/index}">单页管理</a></dd>
				{/if}
				{if in_case_array('admin/brand',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/brand/index}">特约品牌</a></dd>
				{/if}
				{if in_case_array('admin/adPlace',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/adPlace/index}">广告位管理</a></dd>
				{/if}
				{if in_case_array('admin/ad',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/ad/index}">广告管理</a></dd>
				{/if}
			</dl>
		</section>

		<!-- left side end-->


		<!-- main content start-->
		<section class="right-section" id="right-section">
			{include admin.inc.bread}
			<h2 class="header">{$title}</h2>
			<!-- start of inner-frame -->
			<div class="inner-iframe">

				<div class="inner-container">
					<form role="form" class="content-add-form form-horizontal" id="content-add-form" autocomplete="off">
						<input type="hidden" value="{$item.image_url}" name="data[old_image]" class="form-control">
						<!--tmpl-fields-->
						<div class="form-group">
							<label class="col-sm-2 control-label">资讯类型</label>
							<div class="col-sm-4">
							<select name="data[cate_id]" class="form-control">
								{loop $informationCate $cate}
								<option {if $cate['id']==$item['cate_id']}selected{/if} value="{$cate.id}">{$cate.name}</option>
								{/loop}
							</select>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label"><span class="asterisk">*</span>资讯标题</label>
							<div class="col-sm-4">
								<input type="text" value="{$item.title}" name="data[title]" class="form-control" max-length="20" min-length="3" placeholder="资讯标题" required />
								<p class="help-block"></p>
							</div>
							<div class="col-sm-4"><p style="line-height: 40px;">标题字数应为3-20个</p></div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label">图片上传</label>
							<div class="col-sm-4">
								<!--<div id="image-box" class="pull-left">
								</div>
								<div class="pull-left">
									<span name="image_url" class="img-upload text-center img-rounded" id="upload">
										<span class="upload-text"><i class="glyphicon glyphicon-plus">添加图片</i> </span>
										<input type="hidden" name="data[image_url]" id="cimg_url" value="">
									</span>
								</div>-->
								<div class="fileWrap {$companyInfo[idcard_positive] != ''? 'active':''}">

									<div class="fileUpload">
										<input type="hidden" data-id="imgInput" name="data[image_url]" id="cimg_url"  value="{$companyInfo[idcard_positive]}"/>
										<input class="fileBar" id="upload" name="src" type="text" accept="image/gif, image/jpeg, image/jpg, image/png, image/bmp" />
										<div class="btn_file" >
											<!--<div class="icon_add"><i></i></div>
											<p>图片上传</p>-->
											<span class="icon_add"><i class="glyphicon glyphicon-plus">添加图片</i> </span>
										</div>
									</div>
									<div class="uploaded">
										<a class="btn_re" data-act="reUpload" href="javascript:;">删除重新上传</a>
										<p class="img" data-act="big"><img src="{$companyInfo[idcard_positive]}"/></p>
									</div>
								</div>
							</div>
							<p>								【图片比例为：760x470】
							</p>
						</div>
						<p class="help-block"></p>

						<div class="form-group">
							<label class="col-sm-2 control-label">资讯简介</label>
							<div class="col-sm-4">
								<textarea max-length="100" min-length="0" cname="资讯简介" class="form-control editor" style="width: 100%; height: 80px;" name="data[summary]">{$item.summary}</textarea>
							</div>
						</div>
						<p class="help-block"></p>

						<!-- editor -->
						<div class="form-group">
							<label class="col-sm-2 control-label"><span class="asterisk">*</span>资讯内容</label>
							<div class="col-sm-8">
								<textarea required cname="资讯内容" id="editor-content" class="form-control editor" style="width: 100%; height: 240px;" name="data[content]">{$item.content}</textarea>
								<p class="help-block"></p>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label">资讯来源</label>
							<div class="col-sm-4">
							<input type="text" value="{$item.source}" name="data[source]" class="form-control" max-length="20" min-length="3" placeholder="新闻来源" />
							<p class="help-block"></p>
							</div>
							<div class="col-sm-4"><p style="line-height: 40px;">20个字符以内</p></div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label">作者</label>
							<div class="col-sm-4">
								<input type="text" name="data[author]" value="{$item.author}" class="form-control" max-length="15" min-length="3" placeholder="作者姓名"/>
								<p class="help-block"></p>
							</div>
							<div class="col-sm-4"><p style="line-height: 40px;">15个字符以内</p></div>
						</div>


						<div class="form-group">
							<label class="col-sm-2 control-label">来源链接</label>
							<div class="col-sm-4">
								<input type="text" value="{$item.source_link}" name="data[source_link]" class="form-control" max-length="120" min-length="3" placeholder="来源网址" />
								<p class="help-block"></p>
							</div>
							<div class="col-sm-4"><p style="line-height: 40px;">请填写完整的链接，如：http://pvc123.com/</p></div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label">新闻标签</label>
							<div class="col-sm-4">
								<input type="text" value="{$item.tagsStr}" name="data[tags]" class="form-control" max-length="50" min-length="3" placeholder="新闻标签" />
								<p class="help-block"></p>
							</div>
							<div class="col-sm-4"><p style="line-height: 40px;">每个标签之间请用；分开，如“PVC；ABS";三到五个为宜</p></div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label"><span class="asterisk">*</span>跳转链接</label>
							<div class="col-sm-4">
								<input type="radio" name="data[is_jump_link]" value="0" class="icheck"{if $item['is_jump_link']==0}checked{/if}> 是
								&nbsp;&nbsp;&nbsp;
								<input type="radio" name="data[is_jump_link]" value="1" class="icheck" {if $item['is_jump_link']==1}checked{/if}> 否
								<p class="help-block"></p>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label"><span class="asterisk">*</span>是否为推荐</label>
							<div class="col-sm-4">
								<input type="radio" name="data[is_recommend]" value="1" class="icheck"{if $item['is_recommend']==1}checked{/if}>是
								&nbsp;&nbsp;&nbsp;
								<input type="radio" name="data[is_recommend]" value="0" class="icheck" {if $item['is_recommend']==0}checked{/if}>否
								<p class="help-block"></p>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label"><span class="asterisk">*</span>是否发布</label>
							<div class="col-sm-4" style="padding-top: 4px;">
								<input type="radio" name="data[release_status]" value="1" class="icheck"{if $item['release_status']==1}checked{/if}>是
								&nbsp;&nbsp;&nbsp;
								<input type="radio" name="data[release_status]" value="0" class="icheck" {if $item['release_status']==0}checked{/if}>否
								<p class="help-block"></p>
							</div>
						</div>

						<div class="form-group">
							<label class="col-sm-2 control-label">操作人</label>
							<div class="col-sm-4" style="padding-top: 5px;">{$adminName}</div>
						</div>
						<p class="help-block"></p>
						<!--tmpl-assocfields-->
						<div class="btn-group btn-group-or">
							<a href="{if $id==''}{$do_add_url}{else}{$do_edit_url}?id={$id}{/if}" class="btnlg mb ajaxproxy"
								proxy='{"method":"post", "location":"{$index_url}"}'>提交保存</a>

						</div>
					</form><!-- content add form -->
				</div>
			</div><!-- end of inner -->
		</section>
	</div>
</div>
{include admin.inc.footer}

<!--tmpl-script-->

<!-- pagescript -->
<script type="text/javascript">
	seajs.use("admin/informationadd",function (parameter){
		/**--tmpl-templatejavascript--**/
		<!--tmpl-templatejavascript-->
		var $upload = $(".fileWrap");
		parameter.upload_url="{$upload_url}";
		parameter.image_search_url="{$image_search_url}";
		parameter.image_list_url="{$image_list_url}";
		parameter.init();
		parameter.upload({
			datas:['{$item.image_url}'],
			onSuccess : function(data) { //上传一张图片成功回调
				removeImage(data[data.length-2]);   ////当上传多张图片的时候，删除之前的所有图片
				var src = data[data.length-1];
                $upload.find('[data-id="imgInput"]').val(src);
                //图片显示
                $upload.find(".img img").attr("src",src);
                $upload.addClass("active");
			},
			onRemove : function(data) {
				/*$("#cimg_url").val("");*/
				$upload.find('[data-id="imgInput"]').val("");
                $upload.removeClass("active");
				removeImage(data); //用户删除的时候，把图片也连带删除
			},
		});

        $upload.on("click",'[data-act="reUpload"]',function(){
            var $wrap=$(this).closest(".fileWrap");
            var $img = $wrap.find('[data-id="imgInput"]');
            removeImage($img.val()); //用户删除的时候，把图片也连带删除
            $img.val("");
            $wrap.removeClass("active");
        });
        //放大图片
        $('[data-act="big"]').on('click',function(){
            var src= $(this).children("img")[0].src;
            var height = $(window).height()*0.5+'px';
            var width = $(window).width()*0.5+'px';
            var img = '<img src="'+ src+'" style="width: '+width+';height'+height+'">';
            layer.open({
                type: 1,
                title: false,
                shadeClose: true,
                content:img
            })
        });
	});
	function removeImage(data)
	{
		$.get("/admin/information/del_img?image_url="+data,function(result){});
	}


</script>


<script id="assocpage" type="text/html">
<div class="text-right">
	<ul class="pagination blog-pagination">
		<li><a class="assoc-page" data-page="{[prev]}" href="javascript:void(0);">上一页</a></li> 
		{[loop pages page]}
		<li ><a class="assoc-page" data-page="{[page]}" {[if curr == page]}class="active"{[/if]} href="javascript:void(0)">{[page]}</a></li>
		{[/loop]}
		<li><a class="assoc-page" href="javascript:void(0);" data-page="{[nexts]}">下一页</a></li> 
	</ul>	
</div>
</script>

</body>
</html>
